package com.henghai.zhenxuan.ui.page.adapter;

import android.content.Context;

import androidx.recyclerview.widget.RecyclerView;

import com.henghai.zhenxuan.data.bean.SysUserPrizesBean;
import com.henghai.zhenxuan.databinding.AdapterPrizeItemBinding;
import com.kunminx.binding_recyclerview.adapter.SimpleDataBindingAdapter;

public class PrizeListAdapter extends SimpleDataBindingAdapter<SysUserPrizesBean.RowsBean, AdapterPrizeItemBinding> {

    public PrizeListAdapter(Context context) {
        super(context, com.henghai.zhenxuan.R.layout.adapter_prize_item, DiffUtils.getInstance().getPrizeItemCallback());
    }

    @Override
    protected void onBindItem(AdapterPrizeItemBinding adapterTaskItemBinding, SysUserPrizesBean.RowsBean prizeBean, RecyclerView.ViewHolder viewHolder) {
        adapterTaskItemBinding.setProduct(prizeBean);
        adapterTaskItemBinding.itemConversion.setOnClickListener(v -> {
            if (mItemBtClickListener != null) {
                mItemBtClickListener.onConversionClick(prizeBean, viewHolder.getBindingAdapterPosition());
            }
        });
    }


    private OnItemBtClickListener mItemBtClickListener;

    public void setOnItemBtClickListener(OnItemBtClickListener l) {
        this.mItemBtClickListener = l;
    }

    public interface OnItemBtClickListener {

        void onConversionClick(SysUserPrizesBean.RowsBean prizeBean, int position);
    }

}
